<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script src="../js/vue.js"></script>
	</head>
	<body>
		<div id="root">
			<div class="basic" :class="mood"  @click="changeMood">{{ name }}</div>
		</div>
		
		<script type="text/javascript">
			const vm = new Vue({
				el: "#root",
				data: {
					name:'test',
					mood: null
				},
				methods: {
					changeMood(){
						 //vue绑定事件
						 //不要亲手操作dom
						 //随机切换心情
						 const moodsArr = ['normal', 'happy', 'sad'];
						 const random = Math.floor(Math.random() * moodsArr.length);
						 this.mood = moodsArr[random];
					 }
				}
			})
		</script>
		<style>
			.basic{
				width: 400px;
				height: 100px;
				border: 1px solid black;
			}
		
			.happy{
				border: 4px solid red;;
				background-color: rgba(255, 255, 0, 0.644);
				background: linear-gradient(30deg,yellow,pink,orange,yellow);
			}
			.sad{
				border: 4px dashed rgb(2, 197, 2);
				background-color: gray;
			}
			.normal{
				background-color: skyblue;
			}
    
		</style>
	</body>
</html>